﻿using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using VOL.Entity.AttributeManager;
using VOL.Entity.DomainModels.WorkforceManage;
using VOL.SmartMecial.IServices.WorkforceManage;
using VOL.Core.Filters;
using VOL.SmartMecial.Dtos;

namespace VOL.WebApi.Controllers.SmartMecial
{
    [Route("api/ClassBedManageController")]
    [PermissionTable(Name = "ClassBedManageController")]
    public class ClassBedManageController : ControllerBase
    {
        private readonly IClassBedManageService _service;

        public ClassBedManageController(IClassBedManageService service)
        {
            _service = service;
        }

        [HttpGet("GetClassBedManage")]
        public async Task<List<ClassBedManageDTO>> GetClassBedManage()
        {
            return await _service.GetClassBedManages();
        }


        [HttpPost("AddClassBedManages")]
        public async Task<int> AddClassBedManages([FromBody] ClassBedManageModel classBedManageModel)
        {
            return await _service.AddClassBedManages(classBedManageModel);
        }

        [HttpGet("DeleteClassBedManage")]
        public async Task<int> DeleteClassBedManage([FromQuery]int id)
        {
            return await _service.DeleteClassBedManage(id);
        }

        /// <summary>
        /// 修改管床班次
        /// </summary>
        /// <param name="classBedManageModel">管床班次实体</param>
        /// <returns></returns>
        [HttpPost("UpdateClassBedManage")]
        public async Task<IActionResult> UpdateClassBedManage([FromBody] ClassBedManageModel classBedManageModel)
        {
            var result = await _service.UpdateClassBedManage(classBedManageModel);
            if (result > 0)
            {
                return Ok("修改成功");
            }
            else
            {
                return BadRequest("修改失败");
            }
        }
    }
}
